﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace TheTVDB
{
    public class Language
    {
        public int ID { get; set; }
        public string Abbreviation { get; set; }
        public string Name { get; set; }
        public Language()
        {

        }

        public static Language FromXml(XmlElement languageNode)
        {
            Language newLanguage = new Language();
            foreach (XmlElement child in languageNode.ChildNodes)
            {
                switch (child.Name)
                {
                    case "name":
                        newLanguage.Name = child.InnerText;
                        break;
                    case "abbreviation":
                        newLanguage.Abbreviation = child.InnerText;
                        break;
                    case "id":
                        newLanguage.ID = Int32.Parse(child.InnerText);
                        break;
                }
            }
            return newLanguage;
        }
    }
}
